package com.zzmemg.test_flutter

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.PluginRegistry

class MyPlugin : FlutterPlugin {

    companion object {
        @JvmStatic
        fun registerWith(registry: PluginRegistry) {
            val key = MyPlugin::class.java.canonicalName
            if (registry.hasPlugin(key)) {
                return
            }
            val registrarFor = registry.registrarFor(key)
            registrarFor.platformViewRegistry()
                    .registerViewFactory("cn.xqw/custom_platform_view",
                            MyFlutterViewFactory())
        }
    }

    override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
        binding.platformViewRegistry
                .registerViewFactory("cn.xqw/custom_platform_view",
                        MyFlutterViewFactory())
    }

    override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
    }
}